/*
@authors - Siddharth Sathyam, Pat LaMontagna, Alan Ruvalcaba
@Description - Server Header Code

10/13/2011 ssathy2 Written
10/15/2011 ssathy2 Modified. Added Comments
**/

#ifndef SERVER_H
#define SERVER_H

#include <QHash>
#include <QTcpServer>
#include <QTcpSocket>
#include <QVector>
#include <QDebug>
#include <QTime>
#include <QDataStream>
#include <QStringList>

class Server : public QTcpServer
{
        Q_OBJECT
    public:
        Server(QObject *parent = 0);
        bool startServer(QHostAddress addr, quint16 port);

    protected:
        void incomingConnection(int handle);

    public slots:
        void handleIncomingData();
        void handleDisconnection();

    private:
        void sendUsersOnline();
        bool sendMessage(QString messageSentFrom, QString messageSentTo, QString message, QString timeSent);
	QTcpSocket* findSocket(QString userToSendTo);

        QHash<QTcpSocket* , QString> userSocketStringTable;
        QHash<QString, QTcpSocket*> reverseLookupUserSocketStringTable;
};

#endif // SERVER_H
